package leecode.stringAndArray.doublepoint;

public class FindMaxConsecutiveOnes {
    public static void main(String[] args) {
        int res = findMaxConsecutiveOnes(new int[]{1,0,1,1,0,1});
        System.out.println(res);
    }

    /*双指针实现计算数组最大连续数为1的数*/
    public static int findMaxConsecutiveOnes(int[] nums) {
        int res=0,temp=0,left=0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i]==1){
                temp++;
                if(temp>res){
                    res=temp;
                }
            }else {
                temp=0;
            }
        }
        return res;
    }
}
